package com.kasax.plugin.shadow

import com.android.build.api.transform.QualifiedContent
import com.android.build.api.transform.Transform
import com.android.build.api.transform.TransformException
import com.android.build.api.transform.TransformInvocation
import com.android.build.gradle.internal.pipeline.TransformManager
import com.kasax.plugin.shadow.utils.LogUtils

public class CustomLogTransform extends Transform {

    @Override
    String getName() {
        return "CustomLogTransform"
    }

    @Override
    Set<QualifiedContent.ContentType> getInputTypes() {
        return TransformManager.CONTENT_CLASS
    }

    @Override
    Set<? super QualifiedContent.Scope> getScopes() {
        return TransformManager.PROJECT_ONLY
    }

    @Override
    boolean isIncremental() {
        return true
    }

    @Override
    void transform(TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException {
        super.transform(transformInvocation)
        LogUtils.d(getName(), "------------ ------------  transform start  ------------ ------------  ")
        LogUtils.d(getName(), "Current module path: " + transformInvocation.context.path)
        doSth()

        LogUtils.d(getName(), "------------ ------------  transform complete  ------------ ------------  ")
    }

    public void doSth() {
        LogUtils.d(getName(), "doSth")
    }
}